package cn.com.egova.controller;

import cn.com.egova.domain.Account;
import cn.com.egova.service.IAccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * Created by yuanchao on 2020/6/27.
 */
@Controller
@RequestMapping(value = "/account")
public class AccountController {
    @Autowired
    private IAccountService accountService;

    @RequestMapping(value = "/findAll")
    public ModelAndView findAll() {
        System.out.println("Web层findAll方法执行了...");
        List<Account> accounts = accountService.findAll();
        ModelAndView mv = new ModelAndView();
        mv.addObject("list", accounts);
        mv.setViewName("list");
        return mv;
    }


    @RequestMapping(value = "/saveAccount")
    public String saveAccount(Account account) {
        System.out.println("Web层saveAccount方法执行了...");
        accountService.saveAccount(account);
        return "forward:/account/findAll";
    }
}
